from rest_framework import serializers
from apps.news.models import Article, Comment
from apps.users.models import User


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ['id', 'username', 'avatar']  # 需要序列化的字段


class ArticleSerializer(serializers.ModelSerializer):
    class Meta:
        model = Article
        fields = ['id', 'title']  # 需要序列化的字段


class CommentSerializer(serializers.ModelSerializer):
    class Meta:
        model = Comment
        fields = ['id', 'content', 'article', 'parent', "createtime"]  # 需要序列化的字段
